import defaultGeoData from '@/assets/SCdiaster.json'
export const parseGeoData = (geoData = defaultGeoData) => {
  const disasterTypeCounts = {}
  const threatPopulation = []
  const threatProperty = []
  const intensityCounts = {}
  const groundwaterTypeCounts = {}
  const cityCounts = {}
  geoData.features.forEach((feature) => {
    const props = feature.properties
    const type = props.灾害体类型
    // 灾害类型统计
    disasterTypeCounts[type] = (disasterTypeCounts[type] || 0) + 1
    // 灾害人口
    threatPopulation.push({name:props.灾害体名称,value:props.威胁人口})
    // 灾害数量
    threatProperty.push({name:props.灾害体名称,value:props.威胁财产})
    // 地震烈度
    const intensity = props.地震烈度
    intensityCounts[intensity] = (intensityCounts[intensity] || 0) + 1
    // 地下水类型统计
    const groundwaterType = props.地下水类型
    groundwaterTypeCounts[groundwaterType] = (groundwaterTypeCounts[groundwaterType] || 0) + 1
    // 城市统计
    const city = props.市
    if(city) {
      cityCounts[city] = (cityCounts[city] || 0) + 1
    }
  })
  return{
    disasterTypeCounts,
    threatPopulation,
    threatProperty,
    intensityCounts,
    groundwaterTypeCounts,
    cityCounts
  }
}
